from loguru import logger

from com.arcfox.base.base_spider import BaseSpider, ExecuteType
from com.arcfox.util import async_request as requests


class QccSpider(BaseSpider):
    def __init__(self):
        super().__init__()
        self.url = "https://www.qcc.com/web/search"

    async def _pull_task(self):
        tasks = await self.task_manager.pull_tasks(1)
        return tasks, ExecuteType.FINISH

    async def login(self):
        pass

    async def _get_cookies(self):
        pass

    async def _crawl_by_task(self, tasks):
        for task in tasks:
            params = {"key": task}
            resp = await requests.get_with_session(self.url, params, self.get_default_header(), self._get_cookies())
            if resp.code == 200:
                logger.info(resp)
